<?php
ini_set("display_errors", "On");
error_reporting(E_ALL | E_STRICT);
session_start();
if (isset($_POST['openid']) && !empty($_POST['openid'])){
    include '../c/config.php';
    include 'thearray.php';
    $mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
    if (!$mysqli->set_charset("utf8")) {}
    $openid=addslashes(trim($_POST['openid']));
   
    $query=$mysqli->query("SELECT qiuid FROM joinqiu where openid='".$openid."' limit 0,1 ");
    $qiuId='';
    if($query->num_rows>0){
        $getJoin=$query->fetch_assoc();
        $queryQiu=$mysqli->query("SELECT id FROM qdui where id='".$getJoin['qiuid']."' limit 0,1 ");
        $getQiu=$queryQiu->fetch_assoc();
        $qiuId=$getQiu['id'];
    }
    $query=$mysqli->query("SELECT id FROM qdui where openid='".$openid."' limit 0,1 ");
    if($query->num_rows>0){
        $getQiu=$query->fetch_assoc();
        $qiuId=$getQiu['id'];
    }
    $outData=array();
    if (!empty($qiuId)){
        $query=$mysqli->query("SELECT id,openid,qiuhao,weizhi FROM joinqiu where qiuid='".$qiuId."' ");
        while ($list=$query->fetch_assoc()){
            $queryU=$mysqli->query("SELECT * FROM `uinfo` where openid='".$list['openid']."' ");
            $getU=$queryU->fetch_assoc();
            
            $outData[]=array('id'=>$list['id'],'qiuhao'=>$list['qiuhao'],'weizhi'=>$weizhiList[$list['weizhi']],
                'name'=>$getU['name'],'gao'=>$getU['gao'],'weight'=>$getU['weight']);
             
        }
        $qiudName='';
        $query=$mysqli->query("SELECT id,openid,name FROM qdui where id='".$qiuId."' limit 0,1 ");
        while ($list=$query->fetch_assoc()){
            $qiudName=$list['name'];
            $list['qiuhao']=99;
            $queryU=$mysqli->query("SELECT * FROM `uinfo` where openid='".$list['openid']."' ");
            $getU=$queryU->fetch_assoc();
            
            $outData[]=array('id'=>'d'.$list['id'],'qiuhao'=>$list['qiuhao'],'weizhi'=>'',
                'name'=>$getU['name'],'gao'=>$getU['gao'],'weight'=>$getU['weight']);
        }
        
        
    }
    
    $mysqli->close();
    
    echo json_encode(array('d'=>$outData,'n'=>$qiudName,'num'=>count($outData)));
}

